package com.lonwin.mes2u8.domain.u8;

import com.lonwin.mes2u8.domain.mes.MesProductionQueryResult;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author DELL
 * @Date 2023-12-18 15:05
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class U8ProductionAddParam {

    private U8ProductionAddParamInfo productin;

    public static U8ProductionAddParam buildSelfByMesProductions(List<MesProductionQueryResult> mesProductionInfo) {
        U8ProductionAddParamInfo info = U8ProductionAddParamInfo.buildSelfByMesProductionQueryResult(mesProductionInfo.get(0));
        List<U8ProductionAddParamInfoEntry> entries = mesProductionInfo.stream().map(U8ProductionAddParamInfoEntry::buildSelfByMesProduction).collect(Collectors.toList());
        info.setEntry(entries);
        return U8ProductionAddParam.builder().productin(info).build();
    }
}
